package com.ccf.business.etl.controller;

import com.ccf.business.etl.model.Component;
import com.ccf.business.etl.service.IComponentService;
import com.common.model.pojo.Query;
import com.common.model.result.PageResult;
import com.common.model.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 组件表
 *
 * @author ccf
 * @date 2021-11-25 15:36:06
 */
@Slf4j
@RestController
@RequestMapping("/component")
@Api(tags = "组件表")
public class ComponentController {
    @Autowired
    private IComponentService componentService;

    /**
     * 列表
     */
    @ApiOperation(value = "分页查询列表")
    @GetMapping
    public PageResult list(Query query) {
        return componentService.findList(query);
    }


    /**
     * 查询
     */
    @ApiOperation(value = "查询")
    @GetMapping("/{id}")
    public Result getById(@PathVariable String id) {
        Component model = componentService.getById(id);
        return Result.succeed(model, "查询成功");
    }

//    /**
//     * 新增or更新
//     */
//    @ApiOperation(value = "保存")
//    @PostMapping
//    public Result save(@RequestBody Component component) {
//        componentService.saveOrUpdate(component);
//        return Result.succeed("保存成功");
//    }
//
//    /**
//     * 删除
//     */
//    @ApiOperation(value = "删除")
//    @DeleteMapping("/{id}")
//    public Result delete(@PathVariable String id) {
//        //批量删除
//        if (StrUtil.contains(id, ",")){
//            String[] ids = StrUtil.split(id, ",");
//            componentService.removeByIds(Arrays.stream(ids).collect(Collectors.toList()));
//        } else {
//            componentService.removeById(id);
//        }
//        return Result.succeed("删除成功");
//    }

}
